package com.hexus.eve.application;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

/**
 * Provides access to application constants and configuration parameters (they are defined in bean.xml)
 *  
 * @author Mikhail_Berastau 
 */
public class Constants {
	private Logger log = Logger.getLogger(this.getClass());
	
	private static Constants instance;
	
	public static enum Statuses {
		AVAILABLE, UNAVAILABLE, NOT_CHECKED
	}
	
	public enum PropertyNames {
		GLOBAL_KEY, DEFAULT_GROUPS, SERVER_STATUS_SLEEP_TIME, 
		ACCOUNT_SYNCHRONIZATION_INTERVAL, ACCOUNT_AVAILABILITY_CHECK_INTERVAL,
		CHARACTER_SYNCHRONIZATION_INTERVAL, CHARACTER_AVAILABILITY_CHECK_INTERVAL,
		BLUEPRINTS_MARKET_GROUP_ID
	}
	
	private Map<String, String> properties = new HashMap<String, String>();
	
	public Map<String, String> getProperties() {
		return properties;
	}

	public void setProperties(Map<String, String> properties) {
		this.properties = properties;
	}

	public String getProperty(Constants.PropertyNames propertyName) {
		String result = properties.get(propertyName.toString().toLowerCase());
		if(result == null) {
			log.warn("Requested property is missing: " + propertyName);
		}
		return properties.get(propertyName.toString().toLowerCase());
	}

	private Constants(){
		instance = this;
	}
	
	public static Constants getInstance() {
		return instance;
	}
}
